package com.cssw.fyzb.busi.api.live;

import com.cssw.fyzb.core.exception.BizException;
import com.cssw.fyzb.core.model.vo.live.LiveMatchPkVo;
import com.cssw.fyzb.busi.service.live.LiveService;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.Function;
import com.ydn.appserver.annotations.Parameter;
import com.ydn.appserver.annotations.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 同城匹配pk
 * @author yangyiqun
 */
@Function(description = "同城匹配pk", parameters = {
        @Parameter(name = "userId", type = Type.String, description = "用户标识", required = true)
})
@Component
public class SameCityMatchPk implements Action {

    private static final Logger logger = LoggerFactory.getLogger(SameCityMatchPk.class);

    @Autowired
    LiveService liveService;

    @Override
    public Response execute(Request request) throws Exception {
        Long userId = request.getLong("userId");
        try {
            LiveMatchPkVo vo = liveService.sameCityMatchPk(userId);
            return Response.success().put("data", vo);
        } catch (Exception e) {
            if (e instanceof BizException){
                BizException be = (BizException)e;
                return Response.fail(be.getErrMsg(), be.getErrCode());
            }
            logger.error("", e);
            return Response.fail("匹配主播失败");
        }
    }
}





